<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>集群健康 | Elasticsearch: 权威指南 | Elastic</title>
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
</head>
<body>
<div class="main-container">
    <section id="content">
        
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原文地址: <a href="https://www.elastic.co/guide/cn/elasticsearch/guide/current/cluster-health.html" rel="nofollow">https://www.elastic.co/guide/cn/elasticsearch/guide/current/cluster-health.html</a>, 版权归 www.elastic.co 所有<br/>
                            英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/cluster-health.html" rel="nofollow">https://www.elastic.co/guide/en/elasticsearch/guide/current/cluster-health.html</a>
                            </div>
                        <!-- start body -->
                  <div class="page_header">
<b>请注意:</b><br>本书基于 Elasticsearch 2.x 版本，有些内容可能已经过时。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch: 权威指南</a></span>
»
<span class="breadcrumb-link"><a href="getting-started.html">基础入门</a></span>
»
<span class="breadcrumb-link"><a href="distributed-cluster.html">分布式集群</a></span>
»
<span class="breadcrumb-node">集群健康</span>
</div>
<div class="navheader">
<span class="prev">
<a href="_an-empty-cluster.html">« 空集群</a>
</span>
<span class="next">
<a href="_add-an-index.html">添加索引 »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="cluster-health"></a>集群健康<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/edit/cn/020_Distributed_Cluster/10_Cluster_health.asciidoc">edit</a>
</h2>
</div></div></div>
<p>Elasticsearch 的集群监控信息中包含了许多的统计数据，其中最为重要的一项就是 <em>集群健康</em> ，
它在 <code class="literal">status</code> 字段中展示为 <code class="literal">green</code> 、 <code class="literal">yellow</code> 或者 <code class="literal">red</code> 。</p>
<div class="pre_wrapper lang-sense">
<pre class="programlisting prettyprint lang-sense">GET /_cluster/health</pre>
</div>
<div class="sense_widget" data-snippet="snippets/020_Distributed_Cluster/10_Cluster_health.json"></div>
<p>在一个不包含任何索引的空集群中，它将会有一个类似于如下所示的返回内容：</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">{
   "cluster_name":          "elasticsearch",
   "status":                "green", <a id="CO7-1"></a><i class="conum" data-value="1"></i>
   "timed_out":             false,
   "number_of_nodes":       1,
   "number_of_data_nodes":  1,
   "active_primary_shards": 0,
   "active_shards":         0,
   "relocating_shards":     0,
   "initializing_shards":   0,
   "unassigned_shards":     0
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO7-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p><code class="literal">status</code> 字段是我们最关心的。</p>
</td>
</tr>
</table>
</div>
<p><code class="literal">status</code> 字段指示着当前集群在总体上是否工作正常。它的三种颜色含义如下：</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">green</code>
</span>
</dt>
<dd>
所有的主分片和副本分片都正常运行。
</dd>
<dt>
<span class="term">
<code class="literal">yellow</code>
</span>
</dt>
<dd>
所有的主分片都正常运行，但不是所有的副本分片都正常运行。
</dd>
<dt>
<span class="term">
<code class="literal">red</code>
</span>
</dt>
<dd>
有主分片没能正常运行。
</dd>
</dl>
</div>
<p>在本章节剩余的部分，我们将解释什么是 <em>主</em> 分片和 <em>副本</em> 分片，以及上面提到的这些颜色的实际意义。</p>
</div>
<div class="navfooter">
<span class="prev">
<a href="_an-empty-cluster.html">« 空集群</a>
</span>
<span class="next">
<a href="_add-an-index.html">添加索引 »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>